add semi-automated support for spatial and temporal decoherence#41
Closed
tpchuckles wants to merge 2 commits intosimplifyCalculatorWorker2from
Closed
add semi-automated support for spatial and temporal decoherence#41tpchuckles wants to merge 2 commits intosimplifyCalculatorWorker2from
tpchuckles wants to merge 2 commits intosimplifyCalculatorWorker2from
Conversation
…coherence applyShifts, new example 19_coherence.py in tests.
…potentials torch save/load
Owner
|
Changes already merged to dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
do not merge this before PR #39
background
see issue #40
In multislice simulations, we see Fresnel fringes which we don't see IRL, because the gun technically emits a spectrum of wavelengths (temporal decoherence) whereas we model one wavelength, and because the gun is not a point source and there are lens instabilities (spatial decoherence).
you get around this by simulating a range or wavelengths or a range of aberrations and then do an incoherent sum (getting rid of phase info).
changes
To support this, I add a dimension to Probe._array: summable,positional,x,y, so we can easily run multiple different probe configurations (e.g., different wavelengths, or different defocuses or aberrations). Propagate flattens these first two indices, so the traditional positional,x,y indexing for math and caching still works. of course, things like wavelength and eV are now arrays of wavelengths and eVs, so there were some slight math tweaks to handle this.
I also took this opportunity to move the probe position shifting inside of Probe.applyShift instead of using the external function create_batched_probes. Now the probe tracks its own positions, instead of the calculator needing to track and pass through to WFData and HAADFData. this is not universally cleaned up though: WFData still takes probe_xs as an argument for example (TODO, later though).
i then add the new functions: addTemporalDecoherence and addSpatialDecoherence, which sets up the gaussian spread of wavelengths or defocuses. note: in STEM, spatial decoherence means the probe is defocused, but in TEM, the beam is not focused, and "defocus" really means the lens is not projecting the image plane onto your detector. ergo, we have another addSpatialDecoherence function for your exit_wave, which calls WFData.propagate_free_space instead of Probe.defocus
testing
19_coherence.py is added, which demos manual stacking of multiple probes, or the use of the new functions (which should yield the same result). It also demos decoherence in STEM (applied to the probe) and TEM (applied post-sample).
a test case is also added to 18_caching.py, to ensure there is no cross-talk between otherwise-identical simulations with or without decoherence.